package NG::Gen::Users::Helper;
use strict;
use warnings;
use utf8;

use NG::Sys::App;

sub find_base_leader {
	my $self = shift;
	for my $l (@{$self->leaders->list_objects}){
		if($l->proto->{type_i} == 1){
			return $l;
		}
	}
	die "cannot find base leader";
}
sub find_defender_leader {
	my $self = shift;
	my $task = app->constant->defender_task;
	for my $l (@{$self->leaders->list_objects}){
		my $d = $l->d->read_data;
		if($d->{current_task} && $d->{current_task_proto} == $task){
			return $l;
		}
	}
	return 0;
}
1;
